package services.interfaces;

public class ServicesFactory {
	// this Class with create all the Adapters
	
	private static ServicesFactory instance = null;
	private static BillingServiceAdapter billingServiceAdapter = null;
	
	protected ServicesFactory(){
		//Exists only to defeat instantiation.
	}
	
	public static ServicesFactory getInstance(){
		
		if(instance == null){
			instance = new ServicesFactory();
		}
		
		return instance;
	}// end getInstance
	
	
	public ITaxCalculatorAdapter getTaxCalculatorAdapter(String criteria){
		if ( criteria.equals("County") )
		      return new CountyTaxAdapter();
		    else if ( criteria.equals("City") )
		      return new CityTaxAdapter();
		    else if (criteria.equals("Composite"))
		    {
		    	CompositeTaxAdapter composite = new CompositeTaxAdapter();
		    	composite.add(new CountyTaxAdapter());
		    	composite.add(new CityTaxAdapter());
		    	return composite; 
		   
		    }
		
		    return null;
		    
		    //review pg 441 if you have time
	}//end getTaxCalculatorAdapter
	
	public IBillingServiceAdapter getBillingServiceAdapter(){
		if(billingServiceAdapter == null){
			billingServiceAdapter = new BillingServiceAdapter();
		}
		
		return billingServiceAdapter;
	}//end getBillingServiceAdapter
}
